<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Keyboard.pb</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;   PureBasic - Keyboard example file
</font><font color="#006666">;
</font><font color="#006666">;    (c) Fantaisie Software
</font><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font>
<b><font color="#006666">If</font></b> <font color="#006666">InitKeyboard</font>() = 0 <b><font color="#006666">Or</font></b> <font color="#006666">InitSprite</font>() = 0
<font color="#006666">  MessageRequester</font>("Error", "Can't initialize the sprite system.", 0)
  <b><font color="#006666">End</font></b>
<b><font color="#006666">EndIf</font></b>

<font color="#006666">MessageRequester</font>("Information", "This will test the fast keyboard access..."+<font color="#924B72">#LF$</font>+"Press 'ESC' to quit!", 0)


<b><font color="#006666">If</font></b> <font color="#006666">OpenScreen</font>(800, 600, 32, "Keyboard")

  x = 100
  y = 100
  
<font color="#006666">  LoadSprite</font>(0, <font color="#924B72">#PB_Compiler_Home</font> + "examples/sources/Data/PureBasic.bmp")

  <b><font color="#006666">Repeat</font></b>
  
<font color="#006666">    FlipBuffers</font>()
    
<font color="#006666">    ClearScreen</font>(<font color="#006666">RGB</font>(0,0,0))
  
<font color="#006666">    ExamineKeyboard</font>()
    
    <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Left</font>)
      x-1
    <b><font color="#006666">EndIf</font></b>
  
    <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Right</font>)
      x+1
    <b><font color="#006666">EndIf</font></b>
  
    <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Up</font>)
      y-1
    <b><font color="#006666">EndIf</font></b>
  
    <b><font color="#006666">If</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Down</font>)
      y+1
    <b><font color="#006666">EndIf</font></b>
    
    <b><font color="#006666">For</font></b> OffsetY=0 <b><font color="#006666">To</font></b> 600 <b><font color="#006666">Step</font></b> 70
      <b><font color="#006666">For</font></b> OffsetX=0 <b><font color="#006666">To</font></b> 800 <b><font color="#006666">Step</font></b> 200
<font color="#006666">        DisplaySprite</font>(0, OffsetX+x, y+OffsetY)
      <b><font color="#006666">Next</font></b>
      
      <b><font color="#006666">For</font></b> OffsetX=0 <b><font color="#006666">To</font></b> 800 <b><font color="#006666">Step</font></b> 200
<font color="#006666">        DisplaySprite</font>(0, OffsetX+x+90, y+OffsetY+35)
      <b><font color="#006666">Next</font></b>
    <b><font color="#006666">Next</font></b>
    
  <b><font color="#006666">Until</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>)

<b><font color="#006666">Else</font></b>
<font color="#006666">  MessageRequester</font>("Error", "Impossible to open a 800*600 32 bit screen",0)
<b><font color="#006666">EndIf</font></b>

<b><font color="#006666">End</font></b>   </font></pre>
</body></html>
